#ifndef INCLD_H
	#define INCLD_H

	#include <dirent.h>
	#include <iostream>
	#include <stdlib.h>
	#include <fstream>
	#include <vector>

	#include <mysql_connection.h>

	#include <cppconn/driver.h>
	#include <cppconn/exception.h>
	#include <cppconn/resultset.h>
	#include <cppconn/statement.h>

	#include <pcre.h>
	#include "JsonDataModel.h"
	#include <boost/algorithm/string.hpp>
	#include <boost/regex.hpp>
	#include <boost/locale.hpp>
	#include <regex>
	#include <map>
	#include <string>
	using namespace boost::algorithm;
	using namespace std;
	struct Result{
		struct Settings settings;
		map <string,string> columns_map;
		struct Columns columns;
		struct Relative_columns relative_columns;
		int start_line;
		string error;
		string error_rus;
		struct Custom_values custom_values;
		vector<struct Service_marks> service_marks;
	};

int toint(string val);
char* tochar(string val);
string tolower(std::string data);
string alfanumericallowedonly(string str);
string implode(string sep,vector<string> val);
vector<string> relative_reg(string reg,string input);
string p_replace(string reg,string newtext,string str);
string str_replace(string str2, string str3, string str1);
string prepare_price(string price);

	void processLine(string line);
	void processFile(string filename, int id_supplier);
	int makeChecks();
	bool reg1(char* value,char* pattern);
	Result checkPricelistTemplate(string filename);
	string relative_str(Result result,string col,string rel_col);
	void get_new_csv(string column, map<string, string> &csv, string csv_name);
	vector <string> preg_match(string reg,string input);

int continuePricelistString();
void serviceMarkSettingsProcessing(int i, bool from_five_to_four = false);
int uploadPricelist(string file, int id, string local_filename, vector<string> user_config);


// variables

extern map<string, string> csv_data;
extern Result pricelist_config;
extern vector<int> service_mode;
extern vector<map<string, string>> service_mark_settings;

extern vector<vector<map<string, string>>> pricelist_tmp;
extern vector<map<string, string>> pricelist;
extern vector<string> prev_name;
extern vector<string> prev_field;
extern vector<string> prev_name_replaced;
extern vector<string> prev_field_replaced;
extern vector<bool> start_collecting_four;

extern vector<string> line_of_text;
extern map<string, string> csv;

#endif
